package routes

import (
	"github.com/kataras/iris"
	"github.com/siaoynli/goProject/web/bootstrap"
	"github.com/siaoynli/goProject/web/handlers/admin_handlers"
)

func  adminRouter(app *bootstrap.App){

	adminLogin := app.Party("/"+adminPrefix, protect)
	{
		adminLogin.Get("/login",admin_handlers.GetAdminLogin).Name="admin.login"
		adminLogin.Post("/login",admin_handlers.PostAdminLogin).Name="admin.login"

		adminLogin.Get("/register",admin_handlers.GetAdminRegister).Name="admin.register"
		adminLogin.Post("/register",admin_handlers.PostAdminRegister).Name="admin.register"
	}

	app.PartyFunc("/"+adminPrefix, func(admin iris.Party) {

		//模板文件，必须注册到party上
		admin.Layout("layouts/admin.html")
		//管理员中间件
		admin.Use(func(ctx iris.Context) {
			ctx.Next()
		})
		admin.Get("/index",admin_handlers.GetAdminIndex).Name="admin.index"
	})


}